#include "G.h"


bool _G::WithCmd = false;
void _G::StartEvent(char * cmdName, bool hide)
{

	VGCore::IVGDocumentPtr activeDocument = _App->ActiveDocument;
	WithCmd = false;
	if (cmdName != NULL)
	{
		WithCmd = true;
		activeDocument->BeginCommandGroup(_bstr_t(cmdName));
	}
	//_App->CorelScriptTools()->BeginWaitCursor();
	//_App->Status->BeginProgress(_bstr_t(cmdName), VARIANT_TRUE);
	/*activeDocument->PreserveSelection = false;
	activeDocument->SaveSettings("");
	activeDocument->Unit = VGCore::cdrUnit::cdrMillimeter;
	activeDocument->ReferencePoint = VGCore::cdrReferencePoint::cdrTopLeft;
	activeDocument->DrawingOriginX = 0.0;
	activeDocument->DrawingOriginY = 0.0;*/
	if (hide)
	{
		_App->Optimization = VARIANT_TRUE;
	}
}

void _G::EndEvent()
{

	try {
		//Sleep(1000);
		_App->Optimization = VARIANT_FALSE;
		_App->Refresh();
		_App->ActiveWindow->Refresh();
		/*VGCore::IVGDocumentPtr activeDocument = App->ActiveDocument;
		activeDocument->PreserveSelection = VARIANT_TRUE;
		activeDocument->ResetSettings();*/
		if (WithCmd)
		{
			_App->ActiveDocument->EndCommandGroup();
		}
		//_App->Status->EndProgress();
		//_App->CorelScriptTools()->EndWaitCursor();
	}
	catch (std::exception &e) {

	}
}